﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

using JHStock.Update;
using Tools;
using Newtonsoft.Json;

namespace JHStock
{
	public class PathConfig // daypath dayspath means workpath//day
	{
        public PathConfig()
        {
            _ReportbyYears = true;
        }
        public string CwfxFilePath
        {
            get
            {
                if (_ReportbyYears)
                    return WorkPath + "years_cwfx.dat";
                return WorkPath + "reports_cwfx.dat"; ;
            }
        }
        public string IndexPath()
        {
            return dbpath.Replace("Stock.mdb", "allindex.day");
        }      
        public string BlockPath()
        {
            if (szpath != null)
            {
                return szpath.Substring(0, szpath.IndexOf("Vipdoc")) + "T0002\\blocknew\\TXDZ.blk";
            }
            return "TXDZ.blk";
        }                
		public string NowWorkPath()
		{
			return WorkPath+"workpath\\"+TimeStringTools.NowDate()+"\\";
		}
        public bool   CheckWorkPath(){ 
            MFile.ClearEmptyPath(WorkPath+"workpath\\");
            DirectoryInfo dir = new DirectoryInfo(NowWorkPath());
            dir.Create();
        	return true;
        }
        public void SetCwfxType(bool reportbyyeas)
        {
            _ReportbyYears = reportbyyeas;
        }
        public bool IsCwfxReportByYears()
        {
            return _ReportbyYears;
        }
        public string ImgPath()
        {
            return WorkPath + "imgs\\";
        }
        public PathConfig Clone(string path)
        {
            PathConfig pc = new PathConfig();
            pc._ReportbyYears = _ReportbyYears;
            pc.ReLoadCwfx = ReLoadCwfx;
            pc.shpath = shpath;
            pc.szpath = szpath;
            pc.dbpath = dbpath.Replace("\\Data\\","\\"+ path+"\\");
            pc.WorkPath = WorkPath.Replace("\\Data\\","\\"+ path+"\\");            
            return pc;
        }
       
        public string szpath { get; set; }
        public string shpath { get; set; }
        public string dbpath { get; set; }  
        public string WorkPath{ get; set; }
        [JsonIgnore]
        private bool _ReportbyYears;
        [JsonIgnore]
        public bool ReLoadCwfx { get; set; }

    }
	public class UpdateXmlPathConfig
	{
        public string HexinXml { get; set; }
        public string TopTenXml { get; set; }
        public string SinaBounsXml { get; set; }		
	}
	public class OutShowConfig{
		public List<string> ColumnTitles()
        {
            return BaseColumn.Concat(NowBaseColumn).Concat(ActiveColumn).ToList();
        }
        public List<string> ColumnBaseTitles()
        {
            return BaseColumn;
        }
        public List<string> ColumnFinTitles()
        {
            return FinColunm;
        }		
        public List<string> BaseColumn { get; set; }
        public List<string> NowBaseColumn { get; set; }
        public List<string> ActiveColumn { get; set; }
        public List<string> FinColunm { get; set; }
	}
	public class ConditionConfig{	//? List<Conditions	
        public List<string> Conditions { get; set; }
	}
	public class StaticsConfig{
        public bool Debug { get; set; }
        public int BeginDay { get; set; }
        public int EndDay { get; set; }
        public int StaticDays { get; set; }
        public int KDataDaysCount { get; set; }  
        public string wout { get; set; }
    }
    public class TempConfig
    {
        public TempConfig()
        {
            NowMins = 0;
        }
        public int NowMins { get; set; }
    }
}
